package com.wg.redis.controller;

import com.wg.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:
 * @Author WuGang
 * @Date 2021/10/15 20:14
 * @Version 1.0
 */
@Controller
public class RedisController {
    @Autowired
    private RedisService redisService;
    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;
    /**
    * @Description: 1.添加Redis依赖2.配置文件配置链接
    * @Param: [key, value]
    * @return: void
    * @Author: WuGang
    * @Date: 2021/10/15
    */
    @RequestMapping("/put")
    @ResponseBody
    public String put(String key,String value){ //可以不带参数  但是不能不访问方法地址
        redisService.put(key,value);
        return  "redis";
    }

    @RequestMapping("/get")
    @ResponseBody
    public Object get(String key){
        Object o = redisTemplate.opsForValue().get("100111000000");
        return  "o";
    }
}
